package leetcode.day;

public class CountElements {

    public static void main(String[] args) {
        int[] da = {-65982, -69129, -65982, -69129, -65982, -69129, -65982, -69129,
                -69129, -65982, -65982, -69129, -65982, -69129, -69129, -69129,
                -65982, -65982, -69129, -69129, -69129, -69129, -65982, -65982,
                -69129, -65982, -65982, -65982, -69129, -65982, -65982, -65982};
        System.out.println(countElements(da));
    }

    public static int countElements(int[] nums) {
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < nums.length; i++) {
            max = Math.max(nums[i], max);
            min = Math.min(nums[i], min);
        }
        int c1 = 0, c2 = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == max) {
                c1++;
            } else if (nums[i] == min) {
                c2++;
            }
        }
        return nums.length - c1 - c2;
    }
}
